<?php

abstract class Vophper_BasicDao
{			
	private $VophperVo;
	
	function __construct(Vophper_MapperVO $Vophper_MapperVo)
	{
		$this->VophperVo = $Vophper_MapperVo;
	}
	
	function Create()
	{
		return Vophper_Core_Factory::GetInsert($this->VophperVo)->Executar();
	}
	
	function LoadAll()
	{
		return Vophper_Core_Factory::GetSelect($this->VophperVo)->Executar();		
	}		
	
	function LoadById()
	{ 		
		$vophper = Vophper_Core_Factory::GetSelect($this->VophperVo);
		
		//$select = $this->_factorySql->GetSelect($this->_objectVo);
		
		/*$select->InnerJoin('company', 'com_code = del_com_code');*/
		
		$select->setFindById() ;
		
		$result = $select->Executar();	
		
		unset($select);
		
		return $result;
	}	
		
	function Update()
	{				
		return Vophper_Core_Factory::GetUpdate($this->VophperVo)->Executar();
	}
		
	function Delete()
	{
		$delete = $this->_factorySql->GetDelete($this->_objectVo);
		
		$result = $delete->Executar();

		unset($delete);
		
		return $result;
	}
	
	
	/**
	 * Busca todos os registros da tabela
	 * @access public
	 * @return Objects[] Retorna array de objetos carregados
	 */
	function LoadAll()
	{
		$vophper = Vophper_Core_Factory::GetSelect($this->VophperVo)->Executar() ;
		
		return $vophper;		
	}	
	
	
	/**
	 * Busca registro pelo id do objeto
	 * @access public
	 * @return boolean
	 */		

	

	/**
	 * Atualiza dados do objeto na tabela pelo id do objeto
	 * @access public
	 * @return boolean
	 */
	function Update()
	{				
		$update = $this->_factorySql->GetUpdate($this->_objectVo);
		
 		$result = $update->Executar();

 		unset($update);
 		
 		return $result;
	}	
}